$(function(){
    var charColumnObject = document.getElementById('chart-column');
    if (!charColumnObject) return;
    var chartColumn = echarts.init(charColumnObject);
    var data = charColumnObject.getAttribute("rel-data");
    var title = charColumnObject.getAttribute("rel-title");
    var seriesType = charColumnObject.getAttribute("rel-type") || "bar";
    data = JSON.parse(data);
    //console.log(data)
    // 指定图表的配置项和数据
    if ( typeof data.series ==  "undefined" ) {
        var option = {
            title: {
                text: title
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                //   data:[legendDataTitle]
            },
            xAxis: {
                data: data.xAxis,
                axisLabel :{
                    interval:0,
                    rotate:-10
                },
                type: 'category',
                boundaryGap: false,
            },
            yAxis: {},
            series: [{
                //      name: legendDataTitle,
                type: seriesType,
                data: data.data
            }]
        };
    } else {

        $.each(data.series, function(k, v){
            data.series[k]["type"] = seriesType
            data.series[k]["showSymbol"] = true
        })
        var option = {
            title: {
                text: title
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {

                type:"scroll"
                //   data:[legendDataTitle]
            },
            xAxis: {
                data: data.xAxis,
                axisLabel :{
                    interval:0,
                    rotate:-10
                },
                type: 'category',
                boundaryGap: false,
            },
            yAxis: {},
            series: data.series
        };
    }

    // 使用刚指定的配置项和数据显示图表。
    chartColumn.setOption(option);
});